<template>
  <div>

    <el-row justify="center">
      <h1>采购信息查询</h1>
    </el-row>
    <el-row>
      <el-col :span="22">
        <!--查询-->
        <div style="display: flex;justify-content: space-around ">
          <el-form-item label="供应商" style="width: 250px">
            <el-input v-model="paramObj.vendorName"></el-input>
          </el-form-item>
          <el-form-item label="起始日期" style="width: 250px">
            <el-date-picker v-model="paramObj.startDate" type="date" value-format="YYYY-MM-DD"
                            placeholder="请选择起始日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="结束日期" style="width: 250px">
            <el-date-picker v-model="paramObj.endDate" type="date" value-format="YYYY-MM-DD"
                            placeholder="请选择结束日期">
            </el-date-picker>
          </el-form-item>
          <el-button @click="findByItem" type="primary">查询</el-button>

        </div>

        <!--        表格-->

        <el-table :data="buyOrderList.records" stripe style="margin-bottom: 20px" border>
          <el-table-column prop="vendor.name" label="供应商名称"></el-table-column>
          <el-table-column prop="user.realName" label="采购员"></el-table-column>
          <el-table-column prop="createDate" label="采购时间"></el-table-column>
          <el-table-column label="操作">
            <template #default="scope">
              <el-button type="primary" @click="viewInfo(scope.row.id)">查看详情</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--        页码-->
        <el-pagination
            v-model:current-page="paramObj.pageNO"
            v-model:page-size="pageSize"
            background
            layout="prev, pager, next, jumper"
            :total="buyOrderList.total"
            @current-change="findByItem"
        />


        <!--查看弹窗-->
        <el-dialog
            v-model="dialogVisible"
            title="销售信息详情" center>
            <el-form-item label="供应商名称">
              {{vendor.name}}
            </el-form-item>
            <el-form-item label="采购员">
              {{ user.realName }}
            </el-form-item>
          <el-form :inline="true" class="demo-form-inline" >
            <el-form-item label="采购时间">
              {{buyOrder.createDate}}
            </el-form-item>
          </el-form>

            <el-form-item label="出库商品明细">
            </el-form-item>
            <el-table :data="buyOrderInfoList">
              <el-table-column prop="product.name" label="商品名称"></el-table-column>
              <el-table-column prop="product.brand" label="品牌"></el-table-column>
              <el-table-column prop="price" label="成交价"></el-table-column>
              <el-table-column prop="num" label="销售数量"></el-table-column>
            </el-table>
          <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="dialogVisible=false">确定</el-button>
      </span>
          </template>
        </el-dialog>

      </el-col>
    </el-row>







  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      buyOrderList:{},//采购订单分页集合
      pageSize:3,
      buyOrder:{},
      dialogVisible:false,
      paramObj:{pageNO:1},
      user:{},
      vendor:{},
      buyOrderInfoList:[],
      formInline:'',
    }
  },
  methods:{
    findByItem(){
      axios.get("/project/buyOrderInfo/findByItem",{params:this.paramObj}).then(resp=>{
        this.buyOrderList=resp.data
      })
    },
    viewInfo(id){
      this.dialogVisible = true;
      axios.get("/project/buyOrderInfo/findByOrderId",{params:{buyOrderId:id}}).then(resp=>{
        this.buyOrder=resp.data
        this.user=this.buyOrder.user
        this.vendor=this.buyOrder.vendor
        this.buyOrderInfoList=this.buyOrder.buyOrderInfoList
      })

    }
  },
  created() {
    this.findByItem()
  }
}
</script>

<style scoped>

</style>